/**
 * @description product test
 * @author 李哲
 */
const product = require('../../model/Product');


!(async () => {
    //创建商品信息
    // const apple = await product.create({
    //     shopId: '63d0eb36c30f0dc1c77651eb',//山姆会员商店
    //     name: '苹果',
    //     imgUrl: '/images/product/apple.jpeg',
    //     sales: 60,
    //     price: 25,
    //     oldPrice: 30,
    //     tabs: ['all', 'seckill', 'fruit']
    // });
    // const grape = await product.create({
    //     shopId: '63d0eb36c30f0dc1c77651eb',//山姆会员商店
    //     name: '葡萄',
    //     imgUrl: '/images/product/grape.jpg',
    //     sales: 83,
    //     price: 15,
    //     oldPrice: 18,
    //     tabs: ['all', 'seckill', 'fruit']
    // });
    // const watermelon = await product.create({
    //     shopId: '63d0eb36c30f0dc1c77651eb',//山姆会员商店
    //     name: '西瓜',
    //     imgUrl: '/images/product/watermelon.jpg',
    //     sales: 120,
    //     price: 20,
    //     oldPrice: 23,
    //     tabs: ['all', 'seckill', 'fruit']
    // })
    // const WRapple = await product.create({
    //     shopId: '63d0eb5487807c9fadab0e47',//沃尔玛
    //     name: '苹果',
    //     imgUrl: '/images/product/apple.jpg',
    //     sales: 23,
    //     price: 26,
    //     oldPrice: 30,
    //     tabs: ['all', 'seckill', 'fruit']
    // })
    // const WRgrape = await product.create({
    //     shopId: '63d0eb5487807c9fadab0e47',//沃尔玛
    //     name: '葡萄',
    //     imgUrl: '/images/product/grape.jpg',
    //     sales: 123,
    //     price: 14,
    //     oldPrice: 20,
    //     tabs: ['all', 'seckill', 'fruit']
    // })
    // const WRpeach = await product.create({
    //     shopId: '63d0eb5487807c9fadab0e47',//沃尔玛
    //     name: '桃子',
    //     imgUrl: '/images/product/peach.jpg',
    //     sales: 63,
    //     price: 10,
    //     oldPrice: 13,
    //     tabs: ['all', 'seckill', 'fruit']
    // })
    //查询商品信息
    const productList = await product.find({
        shopId: '63d0eb5487807c9fadab0e47',
        tabs: {
            $in: 'seckill'
        }
    }).sort({
        updatedAt: -1
    })
    console.log(productList);
})()